import 'package:flutter/material.dart';
import './Demo/basicLayoutDemo.dart';
import './Demo/i18n/i18n_demo_localizations.dart';
import './Demo/list_item_builder.dart';
import 'Demo/button_navigation_bar_demo.dart';
import 'Demo/basicWidgetDemo.dart';
import 'Demo/basicLayoutDemo.dart';
import 'Demo/basicViewDemo.dart';
import 'Demo/Material_component/sliver_demo.dart';
import 'Demo/navigator_demo.dart';
import 'Demo/Material_component/form_demo.dart';
import 'Demo/Material_component/material_component_demo.dart';
import 'Demo/chip/chip_intro.dart';
import 'Demo/state/state_list_demo.dart';
import 'Demo/Stream/stream_list_demo.dart';
import 'Demo/rxDart/rxDart_list_demo.dart';
import 'Demo/BloC/bloC_list_demo.dart';
import 'Demo/http/http_demo.dart';
import 'Demo/animate/animate_demo.dart';
import 'Demo/i18n/i18n.demo.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

// class CustomApi {
//   // 请求的url
//   static const reqUrl = 'http://49.232.173.220:3001';

//   // 按时间线获取事件
//   static const timelineService = '/data/getTimelineService';

//   // 最新辟谣
//   static const getIndexRumorList = '/data/getIndexRumorList';

//   // 最新防护知识
//   static const getIndexRecommendList = '/data/getIndexRecommendList';

//   // 最新知识百科
//   static const getWikiList = '/data/getWikiList';

//   // 获取整体统计信息
//   static const getStatisticsService = '/data/getStatisticsService';

//   // 获取省份信息
//   static const getAreaStat = '/data/getAreaStat';
// }

// class StorageManager {
//   /// app全局配置
//   static var sp;

//   /// 网络连接
//   var connect;

//   /// 必备数据的初始化操作
//   static init() async {
//     // async 异步操作
//     // sync 同步操作
//     sp = 222;
//   }
// }

void main() => runApp(App());
Function name = (int a) => {print(a)};

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // home: NavigatorDemo(),
      // locale: Locale('en', 'US'),
      localeResolutionCallback:
          (Locale locale, Iterable<Locale> supportLocale) {
        return Locale('en', 'US');
      },
      localizationsDelegates: [
        // I18nDemoLocalizationsDelegate(),
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate
      ],
      supportedLocales: [Locale('en', 'US'), Locale('zh', 'CN')],
      // home: Home(),
      initialRoute: '/',
      routes: {
        '/': (context) => NavigatorDemo(),
        '/about': (context) => PageDemo(title: 'About'),
        '/home': (context) => Home(),
        '/form': (context) => FormDemo(),
        '/mdc': (context) => MaterialComponent(),
        '/chip': (context) => ChipIntroDemo(),
        '/state': (context) => StateListDemo(),
        '/stream': (context) => StreamListDemo(),
        '/rxDart': (context) => RxDartListDemo(),
        '/bloC': (context) => BlocListDemo(),
        '/http': (context) => HttpDemo(),
        '/animate': (context) => AnimateDemo(),
        '/i18n': (context) => I18nDemo()
      },
      theme: ThemeData(
          primarySwatch: Colors.purple,
          highlightColor: Color.fromRGBO(255, 255, 255, 0.5),
          splashColor: Colors.white70,
          accentColor: Colors.yellow),
      debugShowCheckedModeBanner: false,
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 5,
        child: Scaffold(
            floatingActionButton: FloatingActionButton(
              child: Icon(Icons.arrow_back),
              onPressed: () {
                Navigator.pop(context);
              },
            ),
            appBar: AppBar(
              leading: IconButton(
                  icon: Icon(Icons.menu),
                  tooltip: 'Navigation',
                  onPressed: () => debugPrint('Navigation button is pressed')),
              title: Text("wangxh"),
              actions: <Widget>[
                IconButton(
                    icon: Icon(Icons.search),
                    tooltip: 'Navigation',
                    onPressed: () => debugPrint('search button is pressed'))
              ],
              elevation: 0.0,
              bottom: TabBar(
                  unselectedLabelColor: Colors.black38,
                  indicatorColor: Colors.black54,
                  indicatorSize: TabBarIndicatorSize.label,
                  indicatorWeight: 1.0,
                  tabs: <Widget>[
                    Tab(icon: Icon(Icons.local_florist)),
                    Tab(icon: Icon(Icons.change_history)),
                    Tab(icon: Icon(Icons.directions_bike)),
                    Tab(icon: Icon(Icons.save_rounded)),
                    Tab(icon: Icon(Icons.network_cell))
                  ]),
            ),
            body: TabBarView(children: <Widget>[
              ListViewDemo(),
              BasicDemo(),
              BasicLayoutDemo(),
              BasicViewDemo(),
              SliverDemo()
            ]),
            drawer: Container(
                color: Colors.white,
                padding: EdgeInsets.all(8.0),
                child: ListView(
                  padding: EdgeInsets.zero,
                  children: <Widget>[
                    UserAccountsDrawerHeader(
                      accountName: Text('wangxh',
                          style: TextStyle(fontWeight: FontWeight.bold)),
                      accountEmail: Text('75422154asd@gmail.com'),
                      currentAccountPicture: CircleAvatar(
                        backgroundImage: NetworkImage(
                            'https://image.ghub.cn/prd%2Fstatic%2F2020-10-03%2Ftimg+%284%29.jpg'),
                      ),
                      decoration: BoxDecoration(
                          color: Colors.yellow[400],
                          image: DecorationImage(
                              image: NetworkImage(
                                  'https://image.ghub.cn/prd/static/2020-10-04/u%3D2534506313%2C1688529724%26fm%3D26%26gp%3D0.jpg'),
                              fit: BoxFit.cover,
                              colorFilter: ColorFilter.mode(
                                  Colors.yellow[400].withOpacity(0.6),
                                  BlendMode.darken))),
                    ),
                    ListTile(
                        title: Text('Message', textAlign: TextAlign.right),
                        trailing: Icon(Icons.message, color: Colors.blue),
                        onTap: () => Navigator.pop(context)),
                    ListTile(
                        title: Text('Favorite', textAlign: TextAlign.right),
                        trailing: Icon(Icons.favorite, color: Colors.blue),
                        onTap: () => Navigator.pop(context)),
                    ListTile(
                        title: Text('Setting', textAlign: TextAlign.right),
                        trailing: Icon(Icons.settings, color: Colors.blue),
                        onTap: () => Navigator.pop(context))
                  ],
                )),
            bottomNavigationBar: BottomNavigaitonBarDemo()));
  }
}

class Hello extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: new Text(
        'hello mot23332',
        textDirection: TextDirection.ltr,
        style: new TextStyle(
            fontSize: 40.0, fontWeight: FontWeight.w400, color: Colors.yellow),
      ),
    );
  }
}
